sgdk: vdp_bg.h File Reference

sgdk

- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

Classes | Functions | Variables
vdp_bg.h File Reference

VDP background plan support. More...

`#include "bmp.h"`
`#include "vdp.h"`
`#include "vdp_tile.h"`

Go to the source code of this file.

## Classes

struct | Image

## Functions

void | VDP_setHorizontalScroll (VDPPlan plan, s16 value)
| Set plan horizontal scroll (plain scroll mode). 3 horizontal scroll modes are supported:
void | VDP_setHorizontalScrollTile (VDPPlan plan, u16 tile, s16 *values, u16 len, u16 use_dma)
| Set plan horizontal scroll (tile scroll mode). 3 horizontal scroll modes are supported:
void | VDP_setHorizontalScrollLine (VDPPlan plan, u16 line, s16 *values, u16 len, u16 use_dma)
| Set plan horizontal scroll (line scroll mode). 3 horizontal scroll modes are supported:
void | VDP_setVerticalScroll (VDPPlan plan, s16 value)
| Set plan vertical scroll (plain scroll mode). 2 vertical scroll modes are supported:
void | VDP_setVerticalScrollTile (VDPPlan plan, u16 tile, s16 *values, u16 len, u16 use_dma)
| Set plan vertical scroll (2-Tiles scroll mode). 2 vertical scroll modes are supported:
void | VDP_clearPlan (u16 plan, u8 use_dma)
| Clear specified plan.
VDPPlan | VDP_getTextPlan ()
| Returns the plan used to display text.
u16 | VDP_getTextPalette ()
| Returns the palette number used to display text.
u16 | VDP_getTextPriority ()
| Returns the priority used to display text.
void | VDP_setTextPlan (VDPPlan plan)
| Define the plan to use to display text.
void | VDP_setTextPalette (u16 palette)
| Define the palette to use to display text.
void | VDP_setTextPriority (u16 prio)
| Define the priority to use to display text.
void | VDP_drawText (const char *str, u16 x, u16 y)
| Draw text.
void | VDP_clearText (u16 x, u16 y, u16 w)
| Clear text.
void | VDP_clearTextLine (u16 y)
| Clear a complete line of text.
void | VDP_drawTextBG (u16 plan, const char *str, u16 flags, u16 x, u16 y)
| Draw text in backgound plan.
void | VDP_clearTextBG (u16 plan, u16 x, u16 y, u16 w)
| Clear text from background plan.
void | VDP_clearTextLineBG (u16 plan, u16 y)
| Clear a complete line of text from background plan.
u16 | VDP_drawBitmap (u16 plan, const Bitmap *bitmap, u16 x, u16 y)
| Draw Bitmap in specified background plan and at given position.
u16 | VDP_drawBitmapEx (u16 plan, const Bitmap *bitmap, u16 basetile, u16 x, u16 y, u16 loadpal)
| Draw Bitmap in specified background plan and at given position.
u16 | VDP_drawImage (u16 plan, const Image *image, u16 x, u16 y)
| Draw Map in specified background plan and at given position.
u16 | VDP_drawImageEx (u16 plan, const Image *image, u16 basetile, u16 x, u16 y, u16 loadpal, u16 use_dma)
| Draw Map at the specified plan position.

## Variables

u16 | curTileInd

## Detailed Description

VDP background plan support.

Author:
  Stephane Dallongeville

Date:
  08/2011

This unit provides plan A & plan B facilities :

- set scrolling
- clear plan
- draw text in plan

## Function Documentation

void VDP_clearPlan | ( | u16 | plan,
|  | u8 | use_dma
| ) |  |

Clear specified plan.

Parameters:

  plan

  Plan we want to clear.
  Accepted values are:
  - VDP_PLAN_A
  - VDP_PLAN_B

  use_dma | Use DMA or software clear.

Using DMA permit faster clear operation but can lock Z80 execution.

void VDP_clearText | ( | u16 | x,
|  | u16 | y,
|  | u16 | w
| ) |  |

Clear text.

Parameters:

  x | X position (in tile).
  y | y position (in tile).
  w | width to clear (in tile).

This method uses VDP_PLAN_A to draw/clear the text.

void VDP_clearTextBG | ( | u16 | plan,
|  | u16 | x,
|  | u16 | y,
|  | u16 | w
| ) |  |

Clear text from background plan.

Parameters:

  plan

  Plan where we want to clear text.
  Accepted values are:
  - VDP_PLAN_A
  - VDP_PLAN_B

  x | X position (in tile).
  y | y position (in tile).
  w | width to clear (in tile).

void VDP_clearTextLine | ( | u16 | y | ) |

Clear a complete line of text.

Parameters:

  y | y position (in tile).

This method uses VDP_PLAN_A to draw/clear the text.

void VDP_clearTextLineBG | ( | u16 | plan,
|  | u16 | y
| ) |  |

Clear a complete line of text from background plan.

Parameters:

  plan

  Plan where we want to clear text.
  Accepted values are:
  - VDP_PLAN_A
  - VDP_PLAN_B

  y | y position (in tile).

u16 VDP_drawBitmap | ( | u16 | plan,
|  | const Bitmap * | bitmap,
|  | u16 | x,
|  | u16 | y
| ) |  |

Draw Bitmap in specified background plan and at given position.

Parameters:

  plan

  Plan where we want to draw the bitmap.
  Accepted values are:
  - VDP_PLAN_A
  - VDP_PLAN_B

  bitmap | Genesis bitmap (the width and height should be aligned to 8). The Bitmap is unpacked "on the fly" if needed (require some memory).
  x | Plan X position (in tile).
  y | Plan Y position (in tile).

Returns:
  FALSE if there is not enough memory to unpack the specified Bitmap (only if compression was enabled).

This function does "on the fly" 4bpp bitmap conversion to tile data and transfert them to VRAM.
It's very helpful when you use bitmap images but the conversion eats sometime so you should use it only for static screen only.
For "in-game" condition you should use VDP_loadTileData() method with prepared tile data.

See also:
  VDP_loadBMPTileData()

u16 VDP_drawBitmapEx | ( | u16 | plan,
|  | const Bitmap * | bitmap,
|  | u16 | basetile,
|  | u16 | x,
|  | u16 | y,
|  | u16 | loadpal
| ) |  |

Draw Bitmap in specified background plan and at given position.

Parameters:

  plan

  Plan where we want to draw the bitmap.
  Accepted values are:
  - VDP_PLAN_A
  - VDP_PLAN_B

  bitmap | Genesis bitmap (the width and height should be aligned to 8). The Bitmap is unpacked "on the fly" if needed (require some memory).
  basetile | Base tile attributes data (see TILE_ATTR_FULL() macro).
  x | Plan X position (in tile).
  y | Plan Y position (in tile).
  loadpal | Load the bitmap palette information when non zero.

Returns:
  FALSE if there is not enough memory to unpack the specified Bitmap (only if compression was enabled).

This function does "on the fly" 4bpp bitmap conversion to tile data and transfert them to VRAM.
It's very helpful when you use bitmap images but the conversion eats sometime so you should use it only for static screen only.
For "in-game" condition you should use VDP_loadTileData() method with prepared tile data.

See also:
  VDP_loadBMPTileData()

u16 VDP_drawImage | ( | u16 | plan,
|  | const Image * | image,
|  | u16 | x,
|  | u16 | y
| ) |  |

Draw Map in specified background plan and at given position.

Parameters:

  plan

  Plan where we want to draw the map.
  Accepted values are:
  - VDP_PLAN_A
  - VDP_PLAN_B

  image | Image structure to draw. The Image is unpacked "on the fly" if needed (require some memory).
  x | Plan X position (in tile).
  y | Plan Y position (in tile).

Returns:
  FALSE if there is not enough memory to unpack the specified Image (only if compression was enabled).

Load the image tiles data in VRAM and display it at specified tilemap region.

See also:
  VDP_drawImageEx()

u16 VDP_drawImageEx | ( | u16 | plan,
|  | const Image * | image,
|  | u16 | basetile,
|  | u16 | x,
|  | u16 | y,
|  | u16 | loadpal,
|  | u16 | use_dma
| ) |  |

Draw Map at the specified plan position.

Parameters:

  plan

  Plan where we want to load map.
  Accepted values are:
  - VDP_PLAN_A
  - VDP_PLAN_B

  image | Image structure to draw. The Image is unpacked "on the fly" if needed (require some memory).
  basetile | Base tile attributes data (see TILE_ATTR_FULL() macro).
  x | Plan X position (in tile).
  y | Plan Y position (in tile).
  loadpal | Load the bitmap palette information when non zero. Accepted values are: 0 = don't load palette. 1 = HIGH PRIORITY TILE. 0:
  use_dma | Use DMA transfert (faster but can lock Z80 execution).

Returns:
  FALSE if there is not enough memory to unpack the specified Image (only if compression was enabled).

Load the image tiles data in VRAM and display it at specified tilemap region.

See also:
  VDP_drawImage()

void VDP_drawText | ( | const char * | str,
|  | u16 | x,
|  | u16 | y
| ) |  |

Draw text.

Parameters:

  str | String to draw.
  x | X position (in tile).
  y | y position (in tile).

This method uses VDP_PLAN_A to draw the text.
See VDP_setTextPalette() and VDP_setTextPriority().

void VDP_drawTextBG | ( | u16 | plan,
|  | const char * | str,
|  | u16 | flags,
|  | u16 | x,
|  | u16 | y
| ) |  |

Draw text in backgound plan.

Parameters:

  plan

  Plan we want to use to draw text.
  Accepted values are:
  - VDP_PLAN_A
  - VDP_PLAN_B

  str | String to draw.
  flags | tile flags (see TILE_ATTR macro).
  x | X position (in tile).
  y | y position (in tile).

This method uses the specified plan to draw the text.
Each character fit in one tile (8x8 pixels).

u16 VDP_getTextPalette | ( |  | ) |

Returns the palette number used to display text.

See also:
  VDP_drawText(..)
  VDP_clearText(..)

VDPPlan VDP_getTextPlan | ( |  | ) |

Returns the plan used to display text.

Returned value should be either PLAN_A or PLAN_B.

See also:
  VDP_drawText(..)
  VDP_clearText(..)

u16 VDP_getTextPriority | ( |  | ) |

Returns the priority used to display text.

See also:
  VDP_drawText(..)
  VDP_clearText(..)

void VDP_setHorizontalScroll | ( | VDPPlan | plan,
|  | s16 | value
| ) |  |

Set plan horizontal scroll (plain scroll mode).
3 horizontal scroll modes are supported:

- Plain (whole plan)
- Tile (8 pixels bloc)
- Line (per pixel scroll)

Parameters:

  plan

  Plan we want to set the horizontal scroll.
  Accepted values are:
  - PLAN_A
  - PLAN_B

  value | H scroll offset. Negative value will move the plan to the left while positive value will move it to the right.

See also:
  VDP_setScrollingMode() function to change scroll mode.

void VDP_setHorizontalScrollLine | ( | VDPPlan | plan,
|  | u16 | line,
|  | s16 * | values,
|  | u16 | len,
|  | u16 | use_dma
| ) |  |

Set plan horizontal scroll (line scroll mode).
3 horizontal scroll modes are supported:

- Plain (whole plan)
- Tile (8 pixels bloc)
- Line (per pixel scroll)

Parameters:

  plan

  Plan we want to set the horizontal scroll.
  Accepted values are:
  - PLAN_A
  - PLAN_B

  line | First line we want to set the horizontal scroll.
  values | H scroll offsets. Negative values will move the plan to the left while positive values will move it to the right.
  len | Number of line to set.
  use_dma | Use DMA flag (faster for large transfer).

See also:
  VDP_setScrollingMode()

void VDP_setHorizontalScrollTile | ( | VDPPlan | plan,
|  | u16 | tile,
|  | s16 * | values,
|  | u16 | len,
|  | u16 | use_dma
| ) |  |

Set plan horizontal scroll (tile scroll mode).
3 horizontal scroll modes are supported:

- Plain (whole plan)
- Tile (8 pixels bloc)
- Line (per pixel scroll)

Parameters:

  plan

  Plan we want to set the horizontal scroll.
  Accepted values are:
  - PLAN_A
  - PLAN_B

  tile | First tile we want to set the horizontal scroll.
  values | H scroll offsets. Negative values will move the plan to the left while positive values will move it to the right.
  len | Number of tile to set.
  use_dma | Use DMA flag (faster for large transfer).

See also:
  VDP_setScrollingMode() function to change scroll mode.

void VDP_setTextPalette | ( | u16 | palette | ) |

Define the palette to use to display text.

Parameters:

  palette | Palette number.

See also:
  VDP_drawText(..)
  VDP_clearText(..)

void VDP_setTextPlan | ( | VDPPlan | plan | ) |

Define the plan to use to display text.

Parameters:

  plan | Plan where to display text. Accepted values are: PLAN_A PLAN_B

See also:
  VDP_drawText(..)
  VDP_clearText(..)

void VDP_setTextPriority | ( | u16 | prio | ) |

Define the priority to use to display text.

Parameters:

  prio | Priority: 1 = HIGH PRIORITY TILE. 0 = LOW PRIORITY TILE.

See also:
  VDP_drawText(..)
  VDP_clearText(..)

void VDP_setVerticalScroll | ( | VDPPlan | plan,
|  | s16 | value
| ) |  |

Set plan vertical scroll (plain scroll mode). 2 vertical scroll modes are supported:

- Plain (whole plan)
- 2-Tiles (16 pixels bloc)

Parameters:

  plan

  Plan we want to set the vertical scroll.
  Accepted values are:
  - PLAN_A
  - PLAN_B

  value | V scroll offset. Negative value will move the plan down while positive value will move it up.

See also:
  VDP_setScrollingMode()

void VDP_setVerticalScrollTile | ( | VDPPlan | plan,
|  | u16 | tile,
|  | s16 * | values,
|  | u16 | len,
|  | u16 | use_dma
| ) |  |

Set plan vertical scroll (2-Tiles scroll mode). 2 vertical scroll modes are supported:

- Plain (whole plan)
- 2-Tiles (16 pixels bloc)

Parameters:

  plan

  Plan we want to set the vertical scroll.
  Accepted values are:
  - PLAN_A
  - PLAN_B

  tile | First tile we want to set the vertical scroll.
  values | V scroll offsets. Negative values will move the plan down while positive values will move it up.
  len | Number of tile to set.
  use_dma | Use DMA flag (faster for large transfer).

See also:
  VDP_setScrollingMode()

## Variable Documentation

u16 curTileInd

Contains current VRAM tile position where we will upload next tile data.

See also:
  VDP_drawBitmap()
  VDP_drawImage()

All Classes Files Functions Variables Typedefs Enumerations Defines